package com.jh.rq;

import java.util.HashMap;
import java.util.Set;

/**
 * @author Li
 * @Date 2023/4/20 14:14
 */
public class HashMapDemo1 {
    public static void main(String[] args) {
        HashMap<Student,String> sm = new HashMap<>();
        Student s1 = new Student("王明",31);
        Student s2 = new Student("小强",34);
        Student s3 = new Student("李明",33);
        Student s4 = new Student("李明",33);

//        把学生添加到集合中
        sm.put(s1,"成都");
        sm.put(s2,"杭州");
        sm.put(s3,"重庆");
        sm.put(s4,"北京");

        Set<Student> keySet = sm.keySet();
        for (Student s : keySet
             ) {
            System.out.println(s.getName()+"-"+s.getAge()+"-"+sm.get(s));
        }
    }
}
